<?php
namespace app\admin\validate;

class Group extends \app\common\validate\Base {
	protected $rule=[
		'title|用户组标题'=>'length:2,32',
		'rules|用户组规则' => 'check_rule',
		'pid|父节点' => 'regex:\d+|check_id0:Group',
		'status|状态'=> 'check_status'
	];

	protected $create_require=['title','pid','rules'];

	protected function check_module_name($value,$data) {
		if (isset($data['pid']) && $data['pid']==0 && !$value)
			return '对于根节点，必须指定前端模块名称';
		return true;
	}

	protected function check_rule($value) {
		$m=model('Rule');
		if ($m->select($value))
			return true;
		else
			return "没有找到依赖规则";
	}
}
?>